package org.linlinjava.litemall.wx.task;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.core.task.Task;
import org.linlinjava.litemall.core.util.BeanUtil;
import org.linlinjava.litemall.db.domain.LitemallOrder;
import org.linlinjava.litemall.db.service.LitemallOrderService;

public class RentNotReturnOrderUnpaidTask extends Task {
    private final Log logger = LogFactory.getLog(RentNotReturnOrderUnpaidTask.class);
    private int orderId = -1;

    public RentNotReturnOrderUnpaidTask(Integer orderId, Long delayInMilliseconds) {
        super("RentNotReturnOrderUnpaidTask-" + orderId, delayInMilliseconds);
        this.orderId = orderId;
    }

    @Override
    public void run() {
        logger.info("系统开始处理延时任务---不想还书未支付订单");
        LitemallOrderService orderService = BeanUtil.getBean(LitemallOrderService.class);
        LitemallOrder order = orderService.findById(this.orderId);
        if (order == null) {
            return;
        }
        orderService.deleteById(this.orderId);
        logger.info("系统结束处理延时任务---不想还书未支付订单---\" + this.orderId ");
    }


}
